<?php
namespace Admin\Model;

use Think\Model;

class CatModel extends Model{
	
	public function cateadd($catId,$catName,$catIntro,$pid){
		$data=array(
				'cat_id'=>$catId,
				'cat_name'=>$catName,
				'intro'=>$catIntro,
				'parent_id'=>$pid
		);
		
		return $this->add($data);
	}
	
	public function getCate(){
		
	
		return $this->select();
	}
	
	public function fineOne($catId){
		$map['cat_id']=$catId;
		return $this->field('cat_id,cat_name,intro,parent_id')->where($map)->find();
	}
	
	public function cateEdit($catId,$catName,$catIntro,$pid){
			$map['cat_id']=$catId;
			$data=array(
					'cat_id'=>$catId,
					'cat_name'=>$catName,
					'intro'=>$catIntro,
					'parent_id'=>$pid,
			);
	
		return $this->where($map)->save($data);
	}
	
	public function delCate($catId){
		$map['cat_id']=$catId;
		return $this->where($map)->delete();
	}
}